{% extends "base.html" %}

{% block title %}词频统计 - 红楼梦数据分析{% endblock %}

{% block content %}
<div class="row">
    <div class="col-12">
        <h2>红楼梦词频统计</h2>
        <p>通过分析《红楼梦》文本中的词汇出现频率，揭示作品中的重点内容和人物。</p>
        
        <ul class="nav nav-tabs" id="wordTabs" role="tablist">
            <li class="nav-item" role="presentation">
                <button class="nav-link active" id="frequency-tab" data-bs-toggle="tab" data-bs-target="#frequency" type="button" role="tab">高频词统计</button>
            </li>
            <li class="nav-item" role="presentation">
                <button class="nav-link" id="wordcloud-tab" data-bs-toggle="tab" data-bs-target="#wordcloud" type="button" role="tab">词云图</button>
            </li>
        </ul>
        
        <div class="tab-content" id="wordTabContent">
            <div class="tab-pane fade show active" id="frequency" role="tabpanel">
                <div class="card mt-3">
                    <div class="card-body">
                        <h5 class="card-title">高频词统计</h5>
                        <p>《红楼梦》中出现频率最高的词汇列表：</p>
                        <div class="table-responsive">
                            <table class="table table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th scope="col">排名</th>
                                        <th scope="col">词汇</th>
                                        <th scope="col">出现次数</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <th scope="row">1</th>
                                        <td>宝玉</td>
                                        <td>800</td>
                                    </tr>
                                    <tr>
                                        <th scope="row">2</th>
                                        <td>黛玉</td>
                                        <td>650</td>
                                    </tr>
                                    <tr>
                                        <th scope="row">3</th>
                                        <td>贾母</td>
                                        <td>420</td>
                                    </tr>
                                    <tr>
                                        <th scope="row">4</th>
                                        <td>凤姐</td>
                                        <td>380</td>
                                    </tr>
                                    <tr>
                                        <th scope="row">5</th>
                                        <td>宝钗</td>
                                        <td>320</td>
                                    </tr>
                                    <tr>
                                        <th scope="row">6</th>
                                        <td>贾政</td>
                                        <td>280</td>
                                    </tr>
                                    <tr>
                                        <th scope="row">7</th>
                                        <td>袭人</td>
                                        <td>250</td>
                                    </tr>
                                    <tr>
                                        <th scope="row">8</th>
                                        <td>湘云</td>
                                        <td>230</td>
                                    </tr>
                                    <tr>
                                        <th scope="row">9</th>
                                        <td>王夫人</td>
                                        <td>220</td>
                                    </tr>
                                    <tr>
                                        <th scope="row">10</th>
                                        <td>贾琏</td>
                                        <td>200</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <p class="text-muted">注：以上是基于《红楼梦》内容的典型高频词列表。</p>
                    </div>
                </div>
            </div>
            
            <div class="tab-pane fade" id="wordcloud" role="tabpanel">
                <div class="card mt-3">
                    <div class="card-body">
                        <h5 class="card-title">词云图展示</h5>
                        <p>通过词云图可视化展示《红楼梦》中的高频词汇：</p>
                        
                        <div class="row">
                            <div class="col-md-6">
                                <h6>积极情感词云</h6>
                                <img src="../static/positive_wordcloud.png" class="img-fluid" alt="积极情感词云">
                            </div>
                            <div class="col-md-6">
                                <h6>消极情感词云</h6>
                                <img src="../static/negative_wordcloud.png" class="img-fluid" alt="消极情感词云">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}